package com.threeti.mecool.core.domain.model.message;

import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Entity
@Table(name = "DM_SYSTEM_MESSAGE")
public class SystemMessage {
    private Long id;
    private Integer version;
    private Date createdOn = new Date();
    private String creator;
    private String head;
    private String body;
    private String receiver;
    private Date receivedOn;
    private int received;

    public SystemMessage() {}

    public SystemMessage(String receiver, String head, String body) {
        this.receiver = receiver;
        this.head = head;
        this.body = body;
    }

    //<editor-fold desc="getter">
    @Id
    @GeneratedValue
    public Long getId() {
        return id;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    @NotNull
    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    public Date getCreatedOn() {
        return createdOn;
    }

    public String getCreator() {
        return creator;
    }

    @NotNull
    public String getHead() {
        return head;
    }

    @NotNull
    public String getBody() {
        return body;
    }

    @NotNull
    public String getReceiver() {
        return receiver;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    public Date getReceivedOn() {
        return receivedOn;
    }

    public int getReceived() {
        return received;
    }
    //</editor-fold>

    //<editor-fold desc="setter">
    public void setId(Long id) {
        this.id = id;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public void setHead(String head) {
        this.head = head;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public void setReceivedOn(Date receivedOn) {
        this.receivedOn = receivedOn;
    }

    public void setReceived(int received) {
        this.received = received;
    }
    //</editor-fold>
}
